package com.emp.dao.impl;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import com.emp.dao.DeptDao;
import com.emp.entity.Dept;

@Repository
public class DeptDaoImpl  extends JdbcDaoSupport
implements DeptDao{
	@Autowired
	public void setMyDataSource(DataSource dataSource){
		   super.setDataSource(dataSource);
	}

	@Override
	public List<Dept> queryAllDepts() {
		String sql = "select deptno,dname,location from t_dept";
		return getJdbcTemplate().query(sql,
				new BeanPropertyRowMapper<Dept>(Dept.class));		
	}

}
